package com.training.collections.map;

import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.training.collections.vo.Employee;

public class MapExample {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Employee employee0 = new Employee("Naresh", "10");
		Employee employee1 = new Employee("Alex", "10");
		Employee employee2 = new Employee("Kalyan", "10");
		Employee employee3 = new Employee("Varshith", "13");
		Employee employee10 = new Employee("Naresh", "13");
		Employee employee11 = new Employee("Alex", "11");
		Employee employee12 = new Employee("Kalyan", "12");
		Employee employee13 = new Employee("Varshith", "13");

		Map<String, Employee> employeeMap = new HashMap<String, Employee>();

		employeeMap.put("10", employee0);
		employeeMap.put("11", employee1);
		employeeMap.put("12", employee2);
		employeeMap.put("13", employee3);

		employeeMap.put("12", employee3);

		// employeeMap.get("12").display();

		Set<Entry<String, Employee>> entries = employeeMap.entrySet();

		for (Iterator iterator = entries.iterator(); iterator.hasNext();) {
			Entry<String, Employee> entry = (Entry<String, Employee>) iterator
					.next();

			System.out.println(" Key is  -- " + entry.getKey()
					+ "  Value is --");
			entry.getValue().display();

		}

		Set keySet = employeeMap.keySet();

		for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
			String stringKey = (String) iterator.next();

			employeeMap.get(stringKey).display();

		}

	}

}
